import React, { Component } from 'react';
import "./index.css";
import { Card, WingBlank, WhiteSpace } from 'antd-mobile';
import { withRouter } from "react-router-dom";
class UserCard extends Component {
    constructor(props){
        super(props);
        this.cardClick = this.cardClick.bind(this);
    }

    render() {
        return (
            <div>
                {this.props.data.map(item => {
                    return (
                        <WingBlank size="lg" key={item._id}>
                            <WhiteSpace size="lg" />
                            <Card onClick={()=>this.cardClick(item._id)}>
                                <Card.Header
                                    title={item.name}
                                    thumb={item.avatar?require('../../assets/img/'+item.avatar+'.png'):''}
                                    extra={item.type==='boss'?<span className="position">招聘职位：{item.position}</span>:''}
                                />
                                <Card.Body>
                                    {/* 求职者 */}
                                    {item.type==='jobhunter'?<div className="item">技能：{item.skills}</div>:''}
                                    {item.type==='jobhunter'?<div className="item">描述：{item.desc}</div>:''}
                                    {/* 老板 */}
                                    {item.type==='boss'?<div className="item">公司：{item.company}</div>:''}
                                    {item.type==='boss'?<div className="item">薪资：{item.paymoney}</div>:''}
                                    {item.type==='boss'?<div className="item">要求：{item.ask}</div>:''}
                                </Card.Body>
                                {/* <Card.Footer content="footer content" extra={<div>extra footer content</div>} /> */}
                            </Card>
                            <WhiteSpace size="lg" />
                        </WingBlank>
                    )
                })}
            </div>
        )
    }

    cardClick(id){
        this.props.history.push(`/chat/${id}`);
    }
}


export default withRouter(UserCard);